<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - svm_rank_trainer.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2012  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_SVM_RANK_TrAINER_Hh_
<font color='#0000FF'>#define</font> DLIB_SVM_RANK_TrAINER_Hh_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='svm_rank_trainer_abstract.h.html'>svm_rank_trainer_abstract.h</a>"

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='ranking_tools.h.html'>ranking_tools.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../algs.h.html'>../algs.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../optimization.h.html'>../optimization.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='function.h.html'>function.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='kernel.h.html'>kernel.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='sparse_vector.h.html'>sparse_vector.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>iostream<font color='#5555FF'>&gt;</font>

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> matrix_type, 
        <font color='#0000FF'>typename</font> sample_type 
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='oca_problem_ranking_svm'></a>oca_problem_ranking_svm</b> : <font color='#0000FF'>public</font> oca_problem<font color='#5555FF'>&lt;</font>matrix_type <font color='#5555FF'>&gt;</font>
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#009900'>/*
            This class is used as part of the implementation of the svm_rank_trainer
            defined towards the end of this file.
        */</font>

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_type::type scalar_type;

        <b><a name='oca_problem_ranking_svm'></a>oca_problem_ranking_svm</b><font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> scalar_type C_,
            <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> samples_,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>bool</u></font> be_verbose_,
            <font color='#0000FF'>const</font> scalar_type eps_,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> max_iter,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> dims_
        <font face='Lucida Console'>)</font> :
            samples<font face='Lucida Console'>(</font>samples_<font face='Lucida Console'>)</font>,
            C<font face='Lucida Console'>(</font>C_<font face='Lucida Console'>)</font>,
            be_verbose<font face='Lucida Console'>(</font>be_verbose_<font face='Lucida Console'>)</font>,
            eps<font face='Lucida Console'>(</font>eps_<font face='Lucida Console'>)</font>,
            max_iterations<font face='Lucida Console'>(</font>max_iter<font face='Lucida Console'>)</font>,
            dims<font face='Lucida Console'>(</font>dims_<font face='Lucida Console'>)</font>
        <b>{</b>
        <b>}</b>

        <font color='#0000FF'>virtual</font> scalar_type <b><a name='get_c'></a>get_c</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            <font color='#0000FF'>return</font> C;
        <b>}</b>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>long</u></font> <b><a name='get_num_dimensions'></a>get_num_dimensions</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            <font color='#0000FF'>return</font> dims;
        <b>}</b>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>bool</u></font> <b><a name='optimization_status'></a>optimization_status</b> <font face='Lucida Console'>(</font>
            scalar_type current_objective_value,
            scalar_type current_error_gap,
            scalar_type current_risk_value,
            scalar_type current_risk_gap,
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_cutting_planes,
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_iterations
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>be_verbose<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>objective:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> current_objective_value <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>objective gap: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> current_error_gap <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>risk:          </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> current_risk_value <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>risk gap:      </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> current_risk_gap <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>num planes:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> num_cutting_planes <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>iter:          </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> num_iterations <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> endl;
            <b>}</b>

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>num_iterations <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> max_iterations<font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#979000'>true</font>;

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>current_risk_gap <font color='#5555FF'>&lt;</font> eps<font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#979000'>true</font>;

            <font color='#0000FF'>return</font> <font color='#979000'>false</font>;
        <b>}</b>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>bool</u></font> <b><a name='risk_has_lower_bound'></a>risk_has_lower_bound</b> <font face='Lucida Console'>(</font>
            scalar_type<font color='#5555FF'>&amp;</font> lower_bound
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> 
            lower_bound <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>return</font> <font color='#979000'>true</font>; 
        <b>}</b>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='get_risk'></a>get_risk</b> <font face='Lucida Console'>(</font>
            matrix_type<font color='#5555FF'>&amp;</font> w,
            scalar_type<font color='#5555FF'>&amp;</font> risk,
            matrix_type<font color='#5555FF'>&amp;</font> subgradient
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            subgradient.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>w.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            subgradient <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            risk <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

            <font color='#009900'>// Note that we want the risk value to be in terms of the fraction of overall
</font>            <font color='#009900'>// rank flips.  So a risk of 0.1 would mean that rank flips happen &lt; 10% of the
</font>            <font color='#009900'>// time.
</font>

            std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> rel_scores;
            std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> nonrel_scores;
            std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font> rel_counts;
            std::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font> nonrel_counts;

            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> total_pairs <font color='#5555FF'>=</font> <font color='#979000'>0</font>;

            <font color='#009900'>// loop over all the samples and compute the risk and its subgradient at the current solution point w
</font>            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> samples.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <b>{</b>
                rel_scores.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font>samples[i].relevant.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                nonrel_scores.<font color='#BB00BB'>resize</font><font face='Lucida Console'>(</font>samples[i].nonrelevant.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> rel_scores.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    rel_scores[k] <font color='#5555FF'>=</font> <font color='#BB00BB'>dot</font><font face='Lucida Console'>(</font>samples[i].relevant[k], w<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> nonrel_scores.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                    nonrel_scores[k] <font color='#5555FF'>=</font> <font color='#BB00BB'>dot</font><font face='Lucida Console'>(</font>samples[i].nonrelevant[k], w<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#979000'>1</font>;

                <font color='#BB00BB'>count_ranking_inversions</font><font face='Lucida Console'>(</font>rel_scores, nonrel_scores, rel_counts, nonrel_counts<font face='Lucida Console'>)</font>;

                total_pairs <font color='#5555FF'>+</font><font color='#5555FF'>=</font> rel_scores.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>nonrel_scores.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> rel_counts.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>rel_counts[k] <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                    <b>{</b>
                        risk <font color='#5555FF'>-</font><font color='#5555FF'>=</font> rel_counts[k]<font color='#5555FF'>*</font>rel_scores[k];
                        <font color='#BB00BB'>subtract_from</font><font face='Lucida Console'>(</font>subgradient, samples[i].relevant[k], rel_counts[k]<font face='Lucida Console'>)</font>; 
                    <b>}</b>
                <b>}</b>

                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> k <font color='#5555FF'>=</font> <font color='#979000'>0</font>; k <font color='#5555FF'>&lt;</font> nonrel_counts.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>k<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>nonrel_counts[k] <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                    <b>{</b>
                        risk <font color='#5555FF'>+</font><font color='#5555FF'>=</font> nonrel_counts[k]<font color='#5555FF'>*</font>nonrel_scores[k];
                        <font color='#BB00BB'>add_to</font><font face='Lucida Console'>(</font>subgradient, samples[i].nonrelevant[k], nonrel_counts[k]<font face='Lucida Console'>)</font>; 
                    <b>}</b>
                <b>}</b>

            <b>}</b>

            <font color='#0000FF'>const</font> scalar_type scale <font color='#5555FF'>=</font> <font color='#979000'>1.0</font><font color='#5555FF'>/</font>total_pairs;

            risk <font color='#5555FF'>*</font><font color='#5555FF'>=</font> scale;
            subgradient <font color='#5555FF'>=</font> scale<font color='#5555FF'>*</font>subgradient;
        <b>}</b>

    <font color='#0000FF'>private</font>:

    <font color='#009900'>// -----------------------------------------------------
</font>    <font color='#009900'>// -----------------------------------------------------
</font>

        <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> samples;
        <font color='#0000FF'>const</font> scalar_type C;

        <font color='#0000FF'>const</font> <font color='#0000FF'><u>bool</u></font> be_verbose;
        <font color='#0000FF'>const</font> scalar_type eps;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> max_iterations;
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> dims;
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> matrix_type, 
        <font color='#0000FF'>typename</font> sample_type,
        <font color='#0000FF'>typename</font> scalar_type
        <font color='#5555FF'>&gt;</font>
    oca_problem_ranking_svm<font color='#5555FF'>&lt;</font>matrix_type, sample_type<font color='#5555FF'>&gt;</font> <b><a name='make_oca_problem_ranking_svm'></a>make_oca_problem_ranking_svm</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> scalar_type C,
        <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> samples,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>bool</u></font> be_verbose,
        <font color='#0000FF'>const</font> scalar_type eps,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> max_iterations,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> dims
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> oca_problem_ranking_svm<font color='#5555FF'>&lt;</font>matrix_type, sample_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>
            C, samples, be_verbose, eps, max_iterations, dims<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> K 
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='svm_rank_trainer'></a>svm_rank_trainer</b>
    <b>{</b>

    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> K kernel_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> kernel_type::scalar_type scalar_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> kernel_type::sample_type sample_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> kernel_type::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> decision_function<font color='#5555FF'>&lt;</font>kernel_type<font color='#5555FF'>&gt;</font> trained_function_type;

        <font color='#009900'>// You are getting a compiler error on this line because you supplied a non-linear kernel
</font>        <font color='#009900'>// to the svm_rank_trainer object.  You have to use one of the linear kernels with this
</font>        <font color='#009900'>// trainer.
</font>        <b><a name='COMPILE_TIME_ASSERT'></a>COMPILE_TIME_ASSERT</b><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font>K, linear_kernel<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
                             is_same_type<font color='#5555FF'>&lt;</font>K, sparse_linear_kernel<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::value <font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        <b><a name='svm_rank_trainer'></a>svm_rank_trainer</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            C <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
            verbose <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
            eps <font color='#5555FF'>=</font> <font color='#979000'>0.001</font>;
            max_iterations <font color='#5555FF'>=</font> <font color='#979000'>10000</font>;
            learn_nonnegative_weights <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
            last_weight_1 <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
        <b>}</b>

        <font color='#0000FF'>explicit</font> <b><a name='svm_rank_trainer'></a>svm_rank_trainer</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> scalar_type<font color='#5555FF'>&amp;</font> C_ 
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>C_ <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>,
                "<font color='#CC0000'>\t svm_rank_trainer::svm_rank_trainer()</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t C_ must be greater than 0</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t C_:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> C_ 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            C <font color='#5555FF'>=</font> C_;
            verbose <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
            eps <font color='#5555FF'>=</font> <font color='#979000'>0.001</font>;
            max_iterations <font color='#5555FF'>=</font> <font color='#979000'>10000</font>;
            learn_nonnegative_weights <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
            last_weight_1 <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_epsilon'></a>set_epsilon</b> <font face='Lucida Console'>(</font>
            scalar_type eps_
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>eps_ <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>,
                "<font color='#CC0000'>\t void svm_rank_trainer::set_epsilon()</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t eps_ must be greater than 0</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t eps_: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> eps_ 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            eps <font color='#5555FF'>=</font> eps_;
        <b>}</b>

        <font color='#0000FF'>const</font> scalar_type <b><a name='get_epsilon'></a>get_epsilon</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> eps; <b>}</b>

        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='get_max_iterations'></a>get_max_iterations</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> max_iterations; <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_max_iterations'></a>set_max_iterations</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> max_iter
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            max_iterations <font color='#5555FF'>=</font> max_iter;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='be_verbose'></a>be_verbose</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            verbose <font color='#5555FF'>=</font> <font color='#979000'>true</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='be_quiet'></a>be_quiet</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            verbose <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
        <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='forces_last_weight_to_1'></a>forces_last_weight_to_1</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> last_weight_1;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='force_last_weight_to_1'></a>force_last_weight_to_1</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>bool</u></font> should_last_weight_be_1
        <font face='Lucida Console'>)</font>
        <b>{</b>
            last_weight_1 <font color='#5555FF'>=</font> should_last_weight_be_1;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last_weight_1<font face='Lucida Console'>)</font>
                prior.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_oca'></a>set_oca</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> oca<font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font>
        <b>{</b>
            solver <font color='#5555FF'>=</font> item;
        <b>}</b>

        <font color='#0000FF'>const</font> oca <b><a name='get_oca'></a>get_oca</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> solver;
        <b>}</b>

        <font color='#0000FF'>const</font> kernel_type <b><a name='get_kernel'></a>get_kernel</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> <font color='#BB00BB'>kernel_type</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='learns_nonnegative_weights'></a>learns_nonnegative_weights</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> learn_nonnegative_weights; <b>}</b>
       
        <font color='#0000FF'><u>void</u></font> <b><a name='set_learns_nonnegative_weights'></a>set_learns_nonnegative_weights</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>bool</u></font> value
        <font face='Lucida Console'>)</font>
        <b>{</b>
            learn_nonnegative_weights <font color='#5555FF'>=</font> value;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>learn_nonnegative_weights<font face='Lucida Console'>)</font>
                prior.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>; 
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_prior'></a>set_prior</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> trained_function_type<font color='#5555FF'>&amp;</font> prior_
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>prior_.basis_vectors.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                        prior_.<font color='#BB00BB'>alpha</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font>,
                "<font color='#CC0000'>\t void svm_rank_trainer::set_prior()</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t The supplied prior could not have been created by this object's train() method.</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t prior_.basis_vectors.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> prior_.basis_vectors.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t prior_.alpha(0):             </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> prior_.<font color='#BB00BB'>alpha</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            prior <font color='#5555FF'>=</font> <font color='#BB00BB'>sparse_to_dense</font><font face='Lucida Console'>(</font>prior_.<font color='#BB00BB'>basis_vectors</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            learn_nonnegative_weights <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
            last_weight_1 <font color='#5555FF'>=</font> <font color='#979000'>false</font>;
        <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='has_prior'></a>has_prior</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_c'></a>set_c</b> <font face='Lucida Console'>(</font>
            scalar_type C_ 
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>C_ <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>,
                "<font color='#CC0000'>\t void svm_rank_trainer::set_c()</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t C_ must be greater than 0</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t C_:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> C_ 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t this: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            C <font color='#5555FF'>=</font> C_;
        <b>}</b>

        <font color='#0000FF'>const</font> scalar_type <b><a name='get_c'></a>get_c</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> C;
        <b>}</b>

        <font color='#0000FF'>const</font> decision_function<font color='#5555FF'>&lt;</font>kernel_type<font color='#5555FF'>&gt;</font> <b><a name='train'></a>train</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> std::vector<font color='#5555FF'>&lt;</font>ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> samples
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#009900'>// make sure requires clause is not broken
</font>            <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>is_ranking_problem</font><font face='Lucida Console'>(</font>samples<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font>,
                "<font color='#CC0000'>\t decision_function svm_rank_trainer::train(samples)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t invalid inputs were given to this function</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t samples.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> samples.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t is_ranking_problem(samples): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>is_ranking_problem</font><font face='Lucida Console'>(</font>samples<font face='Lucida Console'>)</font>
                <font face='Lucida Console'>)</font>;


            <font color='#0000FF'>typedef</font> matrix<font color='#5555FF'>&lt;</font>scalar_type,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> w_type;
            w_type w;

            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_dims <font color='#5555FF'>=</font> <font color='#BB00BB'>max_index_plus_one</font><font face='Lucida Console'>(</font>samples<font face='Lucida Console'>)</font>;

            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> num_nonnegative <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>learn_nonnegative_weights<font face='Lucida Console'>)</font>
            <b>{</b>
                num_nonnegative <font color='#5555FF'>=</font> num_dims;
            <b>}</b>

            <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> force_weight_1_idx <font color='#5555FF'>=</font> std::numeric_limits<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&gt;</font>::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; 
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>last_weight_1<font face='Lucida Console'>)</font>
            <b>{</b>
                force_weight_1_idx <font color='#5555FF'>=</font> num_dims<font color='#5555FF'>-</font><font color='#979000'>1</font>;
            <b>}</b>

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>has_prior</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>is_matrix<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font>::value<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#009900'>// make sure requires clause is not broken
</font>                    <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>num_dims <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
                        "<font color='#CC0000'>\t decision_function svm_rank_trainer::train(samples)</font>"
                        <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t The dimension of the training vectors must match the dimension of\n</font>"
                        <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t those used to create the prior.</font>"
                        <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t num_dims:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> num_dims 
                        <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t prior.size(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                    <font face='Lucida Console'>)</font>;
                <b>}</b>
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> dims <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font>num_dims, <font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#009900'>// In the case of sparse sample vectors, it is possible that the input
</font>                <font color='#009900'>// vector dimensionality is larger than the prior vector dimensionality.
</font>                <font color='#009900'>// We need to check for this case and pad prior with zeros if it is the
</font>                <font color='#009900'>// case.
</font>                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font><font face='Lucida Console'>)</font>prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> dims<font face='Lucida Console'>)</font>
                <b>{</b>
                    matrix<font color='#5555FF'>&lt;</font>scalar_type,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> prior_temp <font color='#5555FF'>=</font> <font color='#BB00BB'>join_cols</font><font face='Lucida Console'>(</font>prior, zeros_matrix<font color='#5555FF'>&lt;</font>scalar_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>dims<font color='#5555FF'>-</font>prior.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>solver</font><font face='Lucida Console'>(</font> make_oca_problem_ranking_svm<font color='#5555FF'>&lt;</font>w_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>C, samples, verbose, eps, max_iterations, dims<font face='Lucida Console'>)</font>, 
                        w, 
                        prior_temp<font face='Lucida Console'>)</font>;
                <b>}</b>
                <font color='#0000FF'>else</font>
                <b>{</b>
                    <font color='#BB00BB'>solver</font><font face='Lucida Console'>(</font> make_oca_problem_ranking_svm<font color='#5555FF'>&lt;</font>w_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>C, samples, verbose, eps, max_iterations, dims<font face='Lucida Console'>)</font>, 
                        w, 
                        prior<font face='Lucida Console'>)</font>;
                <b>}</b>

            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>solver</font><font face='Lucida Console'>(</font> make_oca_problem_ranking_svm<font color='#5555FF'>&lt;</font>w_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>C, samples, verbose, eps, max_iterations, num_dims<font face='Lucida Console'>)</font>, 
                    w, 
                    num_nonnegative,
                    force_weight_1_idx<font face='Lucida Console'>)</font>;
            <b>}</b>


            <font color='#009900'>// put the solution into a decision function and then return it
</font>            decision_function<font color='#5555FF'>&lt;</font>kernel_type<font color='#5555FF'>&gt;</font> df;
            df.b <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            df.basis_vectors.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#009900'>// Copy the results into the output basis vector.  The output vector might be a
</font>            <font color='#009900'>// sparse vector container so we need to use this special kind of copy to
</font>            <font color='#009900'>// handle that case.
</font>            <font color='#BB00BB'>assign</font><font face='Lucida Console'>(</font>df.<font color='#BB00BB'>basis_vectors</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, matrix_cast<font color='#5555FF'>&lt;</font>scalar_type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>w<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            df.alpha.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            df.<font color='#BB00BB'>alpha</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font color='#979000'>1</font>;

            <font color='#0000FF'>return</font> df;
        <b>}</b>

        <font color='#0000FF'>const</font> decision_function<font color='#5555FF'>&lt;</font>kernel_type<font color='#5555FF'>&gt;</font> <b><a name='train'></a>train</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> sample
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>return</font> <font color='#BB00BB'>train</font><font face='Lucida Console'>(</font>std::vector<font color='#5555FF'>&lt;</font>ranking_pair<font color='#5555FF'>&lt;</font>sample_type<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>, sample<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

    <font color='#0000FF'>private</font>:

        scalar_type C;
        oca solver;
        scalar_type eps;
        <font color='#0000FF'><u>bool</u></font> verbose;
        <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> max_iterations;
        <font color='#0000FF'><u>bool</u></font> learn_nonnegative_weights;
        <font color='#0000FF'><u>bool</u></font> last_weight_1;
        matrix<font color='#5555FF'>&lt;</font>scalar_type,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> prior;
    <b>}</b>; 

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_SVM_RANK_TrAINER_Hh_
</font>

</pre></body></html>